library(ggplot2)
library(grid)
grid.newpage()
pushViewport(viewport(layout = grid.layout(2, 2)))
vplayout <- function(x, y) viewport(layout.pos.row = x, layout.pos.col = y)

p1 <- ggplot(diamonds, aes(carat)) +
  geom_density(bw = 0.01) + labs(title='带宽=0.01')
p2 <- ggplot(diamonds, aes(carat)) +
  geom_density(bw = 0.02)+labs(title='带宽=0.02')
p3 <- ggplot(diamonds, aes(carat)) +
  geom_density(bw = 0.05)+labs(title='带宽=0.05')
p4 <- ggplot(diamonds, aes(carat)) +
  geom_density(bw = 0.1)+labs(title='带宽=0.1')

print(p1, vp = vplayout(1, 1))
print(p2, vp = vplayout(1, 2))
print(p3, vp = vplayout(2, 1))
print(p4, vp = vplayout(2, 2))